﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LinkedListAndRecursion
{
    public class Sum
    {
        public int sum(int[] arr)
        {
            return sum(arr, 0);
        }

        // 计算arr[l...n)这个区间内所有数字的和
        private static int sum(int[] arr, int l)
        {
            if (l == arr.Length)
                return 0;
            return arr[l] + sum(arr, l + 1);
        }
    }
}
